home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_100
/
129_01
/
210ctdl.c
< prev
next >
Wrap
Text File
|
1985-03-09
|
22KB
|
861 lines
/************************************************************************/
/* ctdl.c */
/* Command-interpreter code for Citadel */
/************************************************************************/
#include <210ctdl.h>
/************************************************************************/
/* history */
/* */
/* 84Dec28 HAW doAide modified to list deleted rooms. */
/* 84Dec21 HAW doHelp fixed so that LONG filenames don't bomb system. */
/* 84Dec12 HAW Fixed kill acct. bug that made killed acct. the user. */
/* 84Aug23 HAW & JLS JLS's Forget scheme implemented. */
/* 84JuL12 HAW & JLS <S>kip implemented. */
/* 84JuL06 HAW ALL FILES: make putChar the bottleneck! */
/* 84Jun26 JLS & HAW Commented out extra params to putRoom & getRoom. */
/* 84Jun21 JLS Fix ".Read" so can't have endless "reverse forward..." */
/* 84Jun10 JLS Implement "user must log in to create room." */
/* 84Jun10 JLS Mod for changing date from other than system console. */
/* 84May18 JLS/HAW Greeting modified for coherency. */
/* 84Apr04 HAW Upgrade to BDS 1.50a begun. */
/* 83Mar08 CrT Aide-special functions installed & tested... */
/* 83Feb24 CrT/SB Menus rearranged. */
/* 82Dec06 CrT 2.00 release. */
/* 82Nov05 CrT removed main() from room2.c and split into sub-fn()s */
/************************************************************************/
/************************************************************************/
/* Contents */
/* */
/* doAide() handles Aide-only commands */
/* doChat() handles C(hat) command */
/* doEnter() handles E(nter) command */
/* doForget() handles Z(Forget room) command */
/* doGoto() handles G(oto) command */
/* doHelp() handles H(elp) command */
/* doKnown() handles K(nown rooms) command */
/* doLogin() handles L(ogin) command */
/* doLogout() handles T(erminate) command */
/* doRead() handles R(ead) command */
/* doRegular() fanout for above commands */
/* doSkip() handles S(kip) command */
/* doSysop() handles sysop-only commands */
/* getCommand() prints prompt and gets command char */
/* greeting() System-entry blurb etc */
/* main() has the central menu code */
/************************************************************************/
/************************************************************************/
/* doAide() handles the aide-only menu */
/* return FALSE to fall invisibly into default error msg */
/************************************************************************/
char doAide(moreYet, first)
char moreYet;
char first; /* first parameter if TRUE */
{
char oldName[NAMESIZE];
int rm;
if (!aide) return FALSE;
if (moreYet) first = '\0';
mprintf("ide special fn: ");
if (first) oChar(first);
switch (toUpper( first ? first : iChar() )) {
case 'D':
sprintf(msgBuf.mbtext,
"The following empty rooms deleted by %s: ", logBuf.lbname);
mPrintf("elete empty rooms\n ");
strCpy(oldName, roomBuf.rbname);
indexRooms();
if ((rm=roomExist(oldName)) != ERROR) getRoom(rm);
else getRoom(LOBBY);
aideMessage( /* noteDeletedMessage== */ FALSE );
break;
case 'E':
mprintf("dit room\n \n");
strCpy(oldName, roomBuf.rbname);
if (!renameRoom()) break;
sPrintf(
msgBuf.mbtext,
"%s> edited to %s> by %s",
oldName,
roomBuf.rbname,
logBuf.lbname
);
aideMessage( /* noteDeletedMessage == */ FALSE);
break;
case 'S':
mprintf("et Date\n ");
changedate();
break;
case 'I':
mPrintf("nsert message\n ");
if (
thisRoom == AIDEROOM
||
pulledMLoc == ERROR
) {
mPrintf("nope!");
break;
}
note2Message(pulledMId, pulledMLoc);
putRoom(thisRoom);
noteRoom();
sPrintf(
msgBuf.mbtext,
"Following message inserted in %s> by %s",
roomBuf.rbname,
logBuf.lbname
);
aideMessage( /* noteDeletedMessage == */ TRUE);
break;
case 'K':
mPrintf("ill room\n ");
if (
thisRoom == LOBBY
||
thisRoom == MAILROOM
||
thisRoom == AIDEROOM
) {
mPrintf(" not here!");
break;
}
if (!getYesNo("confirm")) break;
sPrintf(
msgBuf.mbtext,
"%s> killed by %s",
roomBuf.rbname,
logBuf.lbname
);
aideMessage( /* noteDeletedMessage == */ FALSE);
roomBuf.rbflags ^= INUSE;
putRoom(thisRoom);
noteRoom();
getRoom(LOBBY);
break;
case '?':
tutorial("aide.mnu");
break;
default:
if (!expert) mprintf(" ?(Type '?' for menu)\n " );
else mprintf(" ?\n " );
break;
}
return TRUE;
}
/************************************************************************/
/* doChat() */
/************************************************************************/
doChat(moreYet, first)
char moreYet; /* TRUE to accept folliwng parameters */
char first; /* first parameter if TRUE */
{
if (moreYet) first = '\0';
if (first) oChar(first);
mPrintf("hat ");
if (noChat) {
tutorial("nochat.blb");
return;
}
if (whichIO == MODEM) ringSysop();
else interact() ;
}
/************************************************************************/
/* doEnter() handles E(nter) command */
/************************************************************************/
doEnter(moreYet, first)
char moreYet; /* TRUE to accept following parameters */
char first; /* first parameter if TRUE */
{
#define CONFIGURATION 0
#define MESSAGE 1
#define PASSWORD 2
#define ROOM 3
#define FILE 4
char what; /* one of above five */
char abort, done, WC;
char iChar(), toUpper();
if (moreYet) first = '\0';
abort = FALSE ;
done = FALSE ;
WC = FALSE ;
what = MESSAGE;
mprintf("nter ");
if (!loggedIn && !unlogLoginOk && thisRoom!=MAILROOM) {
mprintf("--Must log in to enter (except in Mail>)\n ");
return;
}
if (first) oChar(first);
do {
outFlag = OUTOK;
switch (toUpper( first ? first : iChar() )) {
case '\r':
case '\n':
moreYet = FALSE;
break;
case 'F':
if (roomBuf.rbflags & CPMDIR) {
mprintf("ile upload ");
what = FILE;
done = TRUE;
break;
}
default:
mprintf("? ");
abort = TRUE;
if (expert) break;
case '?':
tutorial("entopt.mnu");
abort = TRUE;
break;
case 'C':
mprintf("onfiguration ");
what = CONFIGURATION;
done = TRUE;
break;
case 'F':
mprintf("ile upload " );
WC = TRUE;
done = TRUE;
break;
case 'M':
mprintf("essage " );
what = MESSAGE;
done = TRUE;
break;
case 'P':
mprintf("assword " );
what = PASSWORD ;
done = TRUE;
break;
case 'R':
mprintf("oom " );
if (!nonAideRoomOk && !aide) {
mPrintf(" ?-- must be aide to create room\n ");
abort = TRUE;
break;
}
if (!loggedIn) {
mprintf("!Must log in to create a new room\n");
abort = TRUE;
break;
}
what = ROOM;
done = TRUE;
break;
}
first = '\0';
} while (!done && moreYet && !abort);
doCR();
if (!abort) {
if (whichIO != CONSOLE && thisRoom == MAILROOM) echo = CALLER;
switch (what) {
case CONFIGURATION : configure() ; break;
case MESSAGE : makeMessage(WC, 0) ; break;
case PASSWORD : newPW() ; break;
case ROOM : makeRoom() ; break;
case FILE : upLoad() ; break;
}
echo = BOTH;
}
}
/************************************************************************/
/* doForget() handles (Forget room) command */
/************************************************************************/
doForget(expand, first)
char expand, first;
{
int i;
if (!expand) {
mPrintf("\bForget %s \n ", roomBuf.rbname);
if (thisRoom == LOBBY ||
thisRoom == MAILROOM ||
thisRoom == AIDEROOM) {
mPrintf("!Can't forget this room! \n ");
return ;
}